# #!/usr/bin/python3
# # -*- coding:utf-8 -*-
# """"
#    @Author: 叶建伟
#    @Email: yejw46507@hundsun.com
#    @Time: 2022/6/14 19:32
#    @File: suspicious_rule_config.py
# """
# <<<<<<< .mine
# import time
# from 线下客户管理.线下客户共用脚本.open_menu import open_menu, arm_form_fill
# from 基础公共脚本.步骤检查_hui2 import check_table, check_table_rows,FE
# from 基础公共脚本.common_util import check_tabs,auto_fill_form,check_label
# =======
# >>>>>>> .r60131
#
# <<<<<<< .mine
# def suspicious_trade_rule(input_data=None, ui_expect=None):
#     open_menu({'子系统名称': '反洗钱系统', '菜单名称': '可疑交易管理/可疑交易规则'})
# =======
# from qturboframe.lib.utils.by import By
# from qturboframe.lib.webdriver import SeleniumError
#
# from BladeFerm.hui2_app import FE
# from BladeFerm.Lib.Common import logger, data_processing
#
# from 基础公共脚本.步骤检查_hui2 import check_ele_text
# from 线下客户管理.线下客户共用脚本.open_menu import open_menu
# >>>>>>> .r60131
#
#
# <<<<<<< .mine
# def suspicious_trade_rule_search(input_data=None, ui_expect=None):
# =======
# @data_processing
# def suspicious_trade_rule_modify(input_data=None, ui_expect=None):
#     logger.info(f'input_data: {input_data}')
#     # 打开菜单
# >>>>>>> .r60131
#     open_menu({'子系统名称': '反洗钱系统', '菜单名称': '可疑交易管理/可疑交易规则'})
# <<<<<<< .mine
# =======
#     # 选择规则
#     select = FE.select(idname={'xpath': '//label[contains(text(),"可疑规则")]//following-sibling::div'})
#     select.set_value_for_single(input_data.get('可疑规则'))
#     # 修改基础信息
#     if input_data.get('基础信息', None):
#         modify_base_info(input_data.get('基础信息'))
#     # 修改配置信息
#     if input_data.get('参数配置', None):
#         modify_config_info(input_data.get('参数配置'))
#     # 检查期望
#     logger.info(f'ui_expect: {ui_expect}')
#     check_ele_text(ui_expect=ui_expect)
# >>>>>>> .r60131
#
#     FE.button(idname={
#         'xpath': '//div[@class="search-item"]/descendant::span[@class="h-select-placeholder"]'}).click()
#     FE.button(idname={
#         'xpath': '//div/ul/li[contains(text(),"' + input_data.get("可疑规则") + '")]'}).click()
#
# <<<<<<< .mine
# def suspicious_trade_rule_updateInfo(input_data=None, ui_expect=None):
#     open_menu({'子系统名称': '反洗钱系统', '菜单名称': '可疑交易管理/可疑交易规则'})
#     FE.button(idname={
#         'xpath': '//div[@class="search-item"]/descendant::span[@class="h-select-placeholder"]'}).click()
#     FE.button(idname={
#         'xpath': '//div/ul/li[contains(text(),"' + input_data.get("可疑规则") + '")]'}).click()
#     FE.button(idname={'xpath': '//h2[contains(text(), "基础信息")]/span/i[contains(@class,"h-icon-editor")]'}).click()
# =======
#
#
# def button_option(base='基础信息', option='修改'):
#     target = FE.list(idname={By.XPATH: f'//h2[@class="base-title" and contains(text(), "{base}")]'})
#     target.foud_target(idname={By.XPATH: './span'})
#     target.click(option)
# >>>>>>> .r60131
#
#
# <<<<<<< .mine
# def suspicious_trade_rule_updatePlan(input_data=None, ui_expect=None):
#     open_menu({'子系统名称': '反洗钱系统', '菜单名称': '可疑交易管理/可疑交易规则'})
#     FE.button(idname={
#         'xpath': '//div[@class="search-item"]/descendant::span[@class="h-select-placeholder"]'}).click()
#     FE.button(idname={
#         'xpath': '//div/ul/li[contains(text(),"' + input_data.get("可疑规则") + '")]'}).click()
#     FE.button(idname={'xpath': '//h2[contains(text(), ",参数配置")]/span/i[contains(@class,"h-icon-editor")]'}).click()
# =======
# def modify_base_info(input_data=None):
#     button_option("基础信息", "修改")
#     if input_data.get('是否启用', None):
#         select1 = FE.select(idname={'xpath': '//th[contains(text(),"是否启用")]//following-sibling::'
#                                              'td//div[contains(@class,"h-select-single")]'})
#         select1.set_value_for_single(input_data.get('是否启用'))
#     if input_data.get('可疑特征', None):
#         select2 = FE.select(idname={'xpath': '//th[contains(text(),"可疑特征")]//following-sibling::'
#                                              'td//div[contains(@class,"h-select-single")]'})
#         select2.set_value_for_single(input_data.get('可疑特征'))
#     if input_data.get('描述', None):
#         input1 = FE.list(idname={'xpath': '//th[contains(text(),"描述")]//following-sibling::'
#                                           'td//div[contains(@class,"h-input-wrapper")]/textarea'})
#         input1.element.clear()
#         input1.element.send_keys(input_data.get('描述'))
#     button_option("基础信息", input_data.get("操作", "保存"))
# >>>>>>> .r60131
#
# <<<<<<< .mine
# =======
#
# def modify_config_info(input_data=None):
#     button_option("参数配置", "修改")
#     next_option = input_data.pop("操作", "保存")
#     __input_element = "h-input-wrapper"
#     __select_element = "h-select-multiple"
#     for key, value in input_data.items():
#         if value == "":
#             continue
#         target_list = input_data.get(key).split(',')
#         ele = FE.driver.find_element_by_attribute(By.XPATH, f'//td[contains(text(),"{key}")]'
#                                                             f'//following-sibling::td/div/div')
#         ele_class = ele.get_attribute("class")
#         if __input_element in ele_class:
#             input2 = FE.input_type(idname={By.XPATH: f'//td[contains(text(),"{key}")]//following-sibling::'
#                                                      'td/div/div[contains(@class,"h-input-wrapper")]'})
#             input2.set_value(value)
#             logger.info(f'{key}，填充：{target_list}')
#         elif __select_element in ele_class:
#             select = FE.select(idname={By.XPATH: f'//td[contains(text(),"{key}")]//following-sibling::'
#                                                  'td/div/div[contains(@class,"h-select-multiple")]'})
#             select.set_value_for_multiple(target_list)
#             select.element.click()
#             logger.info(f'{key}，勾选：{target_list}')
#         else:
#             raise SeleniumError(f'{ele_class} 中存在不支持的类型。')
#     button_option("参数配置", next_option)
#
#
# >>>>>>> .r60131
